package org.example;

import java.sql.Connection;
import java.sql.DriverManager;

/*连接数据库*/
public class GetConnection {
    private Connection con=null;
    public Connection GetConnection(){
        String URL="jdbc:mysql://localhost:3306/soa"+
                "? characterEncoding=utf8 & useSSL=false & serverTimezone=GMT%2B8 & rewriteBatchedStatements=true";
        String USER="hwj";
        String KEY="123456";
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            con= DriverManager.getConnection(URL, USER, KEY);
        } catch (Exception e)
        {
            // TODO 自动生成的 catch 块
            e.printStackTrace();
        }
        return con;
    }}
